gtk-demo: Don't show main window if --run is passed in
authorAlexander Larsson <alexl@redhat.com>
Fri, 29 May 2020 11:51:11 +0000 (13:51 +0200)
committerAlexander Larsson <alexl@redhat.com>
Fri, 29 May 2020 11:51:31 +0000 (13:51 +0200)
Also, in that case, exit when the demo window is closed.

demos/gtk-demo/main.c

index 9d802b8c1fadfceec01f3961e6ba1f31b7cee1e1..3ff4e22b912f2b5b7ea979878bfa6767142b90c1 100644 (file)
@@ -1031,8 +1031,6 @@ activate (GApplication *app)
 
   gtk_tree_view_collapse_all (GTK_TREE_VIEW (treeview));
 
-  gtk_widget_show (GTK_WIDGET (window));
-
   g_object_unref (builder);
 }
 
@@ -1091,11 +1089,11 @@ command_line (GApplication            *app,
       return 0;
     }
 
+  window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
+
   if (name == NULL)
     goto out;
 
-  window = gtk_application_get_windows (GTK_APPLICATION (app))->data;
-
   d = gtk_demos;
 
   while (d->title)
@@ -1125,7 +1123,11 @@ out:
 
       gtk_window_set_transient_for (GTK_WINDOW (demo), GTK_WINDOW (window));
       gtk_window_set_modal (GTK_WINDOW (demo), TRUE);
+
+      g_signal_connect_swapped (G_OBJECT (demo), "destroy", G_CALLBACK (g_application_quit), app);
     }
+  else
+    gtk_widget_show (GTK_WIDGET (window));
 
   if (autoquit)
     g_timeout_add_seconds (1, auto_quit, app);